﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;

namespace AuctionHelper.Core
{
    /// <summary>
    /// 配置辅助类
    /// </summary>
    public class ConfigHelper
    {
        /// <summary>
        /// 获取AppSetting值
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="key"></param>
        /// <returns></returns>
        public static T GetAppSetting<T>(string key)
        {
            return (T)Convert.ChangeType(ConfigurationManager.AppSettings[key], typeof(T));
        }

        /// <summary>
        /// 获取数据文件路径
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public static string GetDataFilePath<T>()
        {
            return AppDomain.CurrentDomain.BaseDirectory + GetAppSetting<string>(typeof(T).Name);
        }

        /// <summary>
        /// 获取图像识别语言包文件路径
        /// </summary>
        /// <returns></returns>
        public static string GetImageFilePath()
        {
            return AppDomain.CurrentDomain.BaseDirectory + string.Format(GetAppSetting<string>("ImageFilePath"), Guid.NewGuid().ToString());
        }
    }
}
